<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时间差</title>
</head>
<body>
    <script>
        var date1 = new Date('2020-6-19 12:00:33');
        var date2 = new Date('2020-7-12 10:12:00');

        // 转格林威治时间时差
        var jetLag = Math.abs(date1.getTime()- date2.getTime());

        // 算出日时分秒
        var second = parseInt((jetLag/1000)%60);
        var minute = parseInt((jetLag/1000/60)%60);
        var hour = parseInt((jetLag/1000/60/60)%24);
        var day = parseInt(jetLag/1000/60/60/24);

        document.write('相差'+day+'天'+hour+'小时'+minute+'分'+second+'秒');
    </script>
</body>
</html>